angular.module('fs.waf').controller('poi.demo.fsButtonsController', [
  '$scope',
  '$q',
  function($scope, $q) {
    var ctrl = this;

    ctrl.ngModel = {};

    ctrl.layoutConfig = {
      demo: {
        name: 'demo',
        gridGroups: [
          {
            grids: ['edit', 'readonly', 'view']
          }
        ],
        gridConfigs: {
          valueText: {
            name: 'text',
            label: 'value',
            size: 2,
            type: 'text',
            model: 'textValue',
            appScope: $scope,
            showStyle: 'edit',
            tooltip: 'value'
          },
          displayText: {
            name: 'text',
            label: 'display',
            size: 2,
            type: 'text',
            model: 'displayText',
            appScope: $scope,
            showStyle: 'edit',
            tooltip: 'display',
            uppercase: false
          },
          changeData: {
            name: 'button',
            label: 'changeData',
            size: 2,
            type: 'button',
            appScope: $scope,
            text: 'Add Data',
            tooltip: 'button tooltip',
            options: {
              icon: 'setup',
              showIcon: false,
              callback: {
                click: 'vm.changeData'
              }
              // hotKey: 'alt+1'
            }
          },
          edit: {
            name: 'buttons',
            label: 'edit',
            model: 'buttonsValue',
            type: 'buttons',
            appScope: $scope,
            buttons: [
              {
                name: 'button',
                label: 'button',
                type: 'button',
                btnScope: $scope,
                options: {
                  icon: 'setup',
                  showIcon: true,
                  callback: {
                    click: 'vm.callbackFunc'
                  },
                  hotKey: 'alt+1'
                }
              }
            ]
          }
        }
      }
    };

    ctrl.options = {
      data: [
        {
          disabled: false,
          display: 'Jack',
          value: 123
        },
        {
          disabled: false,
          display: 'Lee',
          value: 456
        }
      ]
    };

    ctrl.normalData = [
      {
        disabled: false,
        display: 'Jack',
        value: 123
      },
      {
        disabled: false,
        display: 'Lee',
        value: 456
      }
    ];

    ctrl.componentStyle = [
      {
        value: 'edit',
        display: 'edit'
      },
      {
        value: 'readonly',
        display: 'readonly'
      },
      {
        value: 'view',
        display: 'view'
      }
    ];

    ctrl.changeData = function() {
      if (ctrl.ngModel.textValue && ctrl.ngModel.displayText) {
        ctrl.normalData.push({
          value: ctrl.ngModel.textValue,
          display: ctrl.ngModel.displayText
        });
      }
    };

    ctrl.clickFun = function() {
      console.log(ctrl.ngModel.linkValue);
    };

    ctrl.callbackFunc = function() {
      alert('callback function');
    };
  }
]);
